﻿#include "mainwindow.h"
#include <QApplication>
#include <QFontDatabase>
#include <QIODevice>
#include <QFile>
#include <QDebug>
quint32 program_version = 0x01000101; //1.1.1

QString loadFontFamilyFromFiles(const QString &fontFileName)
{
    QString font = "";

    QFile fontFile(fontFileName);
    if(!fontFile.open(QIODevice::ReadOnly))
    {
        qDebug()<<"Open font file error";
        return font;
    }

    int loadedFontID = QFontDatabase::addApplicationFontFromData(fontFile.readAll());
    QStringList loadedFontFamilies = QFontDatabase::applicationFontFamilies(loadedFontID);
    if(!loadedFontFamilies.empty())
    {
        font = loadedFontFamilies.at(0);
    }
    fontFile.close();
    return font;
}

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
//    QString strFont0 =  loadFontFamilyFromFiles("fonts\\FangZhengHeiTiJianTi.ttf");
//    qDebug() << "strFont0 is: " << strFont0;
//    a.setFont(strFont0);
//    QFont font;
//    font.setFamily(strFont0);
//    a.setFont(font);
//    qApp->setFont(font);
    w.show();
    return a.exec();
}
